<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="renderer" content="webkit">
    <link rel="stylesheet" href="/mdui/css/mdui.min.css">
    <script defer src="/mdui/js/mdui.min.js"></script>
    <script src="/js/axios.min.js"></script>
    <script src="/js/qs.min.js"></script>
    <script src="/js/common.js"></script>
    <script src="/js/vue.js"></script>
</head>
<body class="mdui-theme-primary-indigo mdui-theme-accent-pink">
<div class="mdui-container-fluid" id="app">
    <h1 class="mdui-text-color-theme">提交报修单</h1>
    <!-- 固定标签 -->
    <form>
        <div class="mdui-textfield">
            <i class="mdui-icon material-icons">details</i>
            <label class="mdui-textfield-label">故障详情</label>
            <input class=" mdui-textfield-input" type="text" v-model="detail" name="detail"/>
        </div>
        <!-- 固定标签 -->
        <div class="mdui-textfield">
            <i class="mdui-icon material-icons">place</i>
            <label class="mdui-textfield-label">故障地点</label>
            <input class="mdui-textfield-input" type="text" v-model="place" name="place"/>
        </div>
        <!-- 固定标签 -->
        <div class="mdui-textfield">
            <i class="mdui-icon material-icons">insert_photo</i>
            <label class="mdui-textfield-label">图片</label>
            <input class=" mdui-textfield-input" type="file" id="file" name="file"/>
        </div>
    </form>

    <div style="text-align: center">
        <button @click="adduser" class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-green-800">提交</button>
        <a href="list.html" class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-green-800">返回</a>
    </div>
</div>
<script>
    new Vue({
        el: '#app',
        data: {
            repair: {
                status: "",
                detail: "",
                place: "",
                picMD5: "",
                submitTime: '',
                studentId: ""
            },
            detail: "",
            place: ""
        },
        created() {

        },
        methods: {
            adduser() {
                if (this.detail == "" || this.place == "") {
                    mdui.alert("内容")
                    return;
                }
                let _this = this;
                let fd = new FormData(document.forms[0])//form里的输入框要有name属性
                console.log(fd)
                axios.post("/repair/addRepair", fd)
                    .then(function (res) {
                        if (res.data.success) {
                            mdui.alert("新增成功");
                            _this.place = ''
                            _this.detail = ''
                            _this.fd = ''
                            _this.repair = {
                                status: "",
                                detail: "",
                                place: "",
                                picMD5: "",
                                submitTime: '',
                                studentId: ""
                            }
                        }
                    })
            },
        }
    })
</script>


</body>
</html>